Skip to content

Big query system cleanups#152636

Merged
rust-bors[bot] merged 5 commits intorust-lang:mainfrom
nnethercote:big-cleanups
Feb 16, 2026
Merged

Big query system cleanups#152636
rust-bors[bot] merged 5 commits intorust-lang:mainfrom
nnethercote:big-cleanups

Conversation

@nnethercote
Copy link
Contributor

@nnethercote nnethercote commented Feb 15, 2026

Recent PRs have moved a lot of code from rustc_query_system to rustc_middle and rustc_query_impl, where this code now has access to TyCtxt, e.g. #152419, #152516. As a result, a lot of abstraction and indirection that existed to work around this limitation is no longer necessary. This PR removes a lot of it.

r? @Zalathar

`rustc_query_system` has been reduced so much that it's no longer
needed. This avoids a lot of indirection and abstraction.
By removing the generic `D` parameter from `DepGraph`, `DepGraphData`,
`CurrentDepGraph`, `SerializedDepGraph`, `SerializedNodeHeader`, and
`EncoderState`.
It's no longer needed.
It's no longer needed now that we can access `TyCtxt` directly.
By moving most of it into `DepKind`, and changing two methods into free
functions.
@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 15, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 15, 2026

Zalathar is not on the review rotation at the moment.
They may take a while to respond.

@nnethercote
Copy link
Contributor Author

cc @cjgillot @oli-obk @Zoxc

@Zalathar
Copy link
Member

Let's queue up the precautionary perf run while I'm reviewing the changes.

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Feb 15, 2026
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 15, 2026
Comment on lines -43 to -44
/// Implements [`QueryContext`] for use by [`rustc_query_system`], since that
/// crate does not have direct access to [`TyCtxt`].
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: If we're removing this comment, maybe leave behind a FIXME for getting rid of QueryCtxt entirely.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Though removing QueryCtxt turns out to not be particularly hard, so if we do it next then there's not much value in a FIXME.)

Copy link
Contributor

@petrochenkov petrochenkov Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: If we're removing this comment, maybe leave behind a FIXME for getting rid of QueryCtxt entirely.

+1, when reviewing I was also wondering why struct QueryCtxt itself wasn't removed.

@Zalathar
Copy link
Member

Very minor commit style nit: When removing traits, I like to write “Remove trait Foo” to make it immediately obvious that the thing being removed is a trait and not a type.

}

fn with_reduced_queries<T>(self, _: impl FnOnce() -> T) -> T;
pub trait HasDepContext<'tcx>: Copy {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Maybe leave behind a FIXME to look into renaming or removing HasDepContext.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Though this turns out to also be a fairly easy follow-up.)

@Zalathar
Copy link
Member

Looks good, all very mechanical and straightforward.

r=me after considering the suggestions, assuming perf is good.

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 15, 2026

☀️ Try build successful (CI)
Build commit: 0ede0e7 (0ede0e7634f5edd2cdae2ab91b838980036b30ae, parent: a33907a7a5381473eec8bcfa0c56e05a856a911c)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (0ede0e7): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.3% [0.2%, 0.4%] 12
Regressions ❌
(secondary)
0.3% [0.2%, 0.3%] 8
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.3% [-0.5%, -0.1%] 2
All ❌✅ (primary) 0.3% [0.2%, 0.4%] 12

Max RSS (memory usage)

Results (primary 0.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.6% [2.6%, 2.6%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.1% [-2.1%, -2.1%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.2% [-2.1%, 2.6%] 2

Cycles

Results (secondary 1.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
6.2% [4.3%, 8.1%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.5% [-2.8%, -2.3%] 3
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 483.617s -> 481.529s (-0.43%)
Artifact size: 397.94 MiB -> 395.74 MiB (-0.55%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Feb 15, 2026
@nnethercote
Copy link
Contributor Author

To answer all the above questions: I have a todo list I am working through. I have various follow-up commits already written to remove more stuff. I haven't published those yet because I don't want individual PRs to get too big. I'm not bothering to put "FIXME: remove this" comments on things that I know I will be removing soon. QueryCtxt is definitely on the todo list and won't be difficult. HasDepContext is also on the list but is a little weirder; if it can't be removed it should at least be renamed HasTyCtxt.

I will look at the small perf regressions today. Hopefully they can be fixed with a small tweak to inlining or something like that.

@nnethercote
Copy link
Contributor Author

I investigated the perf results.

  • Local measurements show similarly small regressions, but the set of affected benchmarks is entirely different. The worst-affected primary benchmark on CI is bitmaps-3.2.1 which doesn't show up in my local regressions list. The worst-affected primary benchmark locally is libc-0.2.172 which doesn't show up on the CI regressions list.
  • The cachegrind diffs show small perturbations over a range of functions, some a little better, some a little worse. Although the net result is worse, just scanning through the list it's not obvious which direction the net effect is, and there's no clear single cause. The differences are a few million instructions here and there, which are very small numbers. Hash table functions (e.g. insertion) do show up a few times.
  • Based on the diffs, I think slight changes in inlining is responsible for some or most of this. The code changes are purely "administrative", e.g. changes in types, and a bit of moving code around. There is no change to the amount of actual work (computation, data traversal, etc.) being done.
  • So I think this is all-but-meaningless perturbation. Only 22 runs out of 584 (3.7%) reach the significance threshold, and the worst regression is only 0.40%.

Based on all this, and the fact that these are good code simplification changes and there are lots more follow-up changes waiting on these, I will declare this perf loss as negligible and acceptable and not worth further investigation.

@rustbot label: +perf-regression-triaged
@bors r=Zalathar

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 15, 2026

📌 Commit fcea886 has been approved by Zalathar

It is now in the queue for this repository.

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Feb 15, 2026
@rust-bors rust-bors bot added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Feb 15, 2026
@rust-bors rust-bors bot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 15, 2026
@nnethercote
Copy link
Contributor Author

@bors p=1 (conflict-prone, and blocking follow-up work)

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Feb 16, 2026
Big query system cleanups

Recent PRs have moved a lot of code from `rustc_query_system` to `rustc_middle` and `rustc_query_impl`, where this code now has access to `TyCtxt`, e.g. #152419, #152516. As a result, a lot of abstraction and indirection that existed to work around this limitation is no longer necessary. This PR removes a lot of it.

r? @Zalathar
@rust-bors rust-bors bot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 16, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 16, 2026

💔 Test for a61003d failed: CI. Failed job:

@Zalathar
Copy link
Member

Zalathar commented Feb 16, 2026

A CI runner flaked out for no observable reason.

@bors retry

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 16, 2026
@Zalathar
Copy link
Member

@bors p=5

@rust-bors

This comment has been minimized.

@rust-bors rust-bors bot added merged-by-bors This PR was explicitly merged by bors. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 16, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 16, 2026

☀️ Test successful - CI
Approved by: Zalathar
Duration: 4h 17m 23s
Pushing fef627b to main...

@rust-bors rust-bors bot merged commit fef627b into rust-lang:main Feb 16, 2026
13 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Feb 16, 2026
@github-actions
Copy link
Contributor

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 1396514 (parent) -> fef627b (this PR)

Test differences

Show 6 test diffs

6 doctest diffs were found. These are ignored, as they are noisy.

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard fef627b1ebdc7369ddf8a4031a5d25733ac1fb34 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-apple-various: 1h 42m -> 2h 2m (+19.3%)
  2. x86_64-gnu-llvm-21-2: 1h 36m -> 1h 24m (-12.5%)
  3. dist-x86_64-apple: 2h 10m -> 2h 24m (+10.9%)
  4. dist-arm-linux-gnueabi: 1h 30m -> 1h 20m (-10.8%)
  5. dist-aarch64-apple: 2h -> 2h 12m (+9.4%)
  6. x86_64-gnu: 2h 16m -> 2h 4m (-8.6%)
  7. aarch64-apple: 4h 34m -> 4h 10m (-8.5%)
  8. dist-ohos-aarch64: 1h 13m -> 1h 19m (+8.2%)
  9. dist-i686-mingw: 2h 48m -> 2h 35m (-7.9%)
  10. x86_64-msvc-ext3: 1h 58m -> 1h 49m (-7.8%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@Zoxc
Copy link
Contributor

Zoxc commented Feb 16, 2026

HasDepContext is also on the list but is a little weirder; if it can't be removed it should at least be renamed HasTyCtxt.

#151968 does show how to remove it, but it needs a rebase or two.

@nnethercote nnethercote deleted the big-cleanups branch February 16, 2026 08:59
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (fef627b): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.3% [0.2%, 0.4%] 10
Regressions ❌
(secondary)
0.2% [0.1%, 0.3%] 9
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.4% [-0.4%, -0.3%] 4
All ❌✅ (primary) 0.3% [0.2%, 0.4%] 10

Max RSS (memory usage)

Results (primary 1.7%, secondary -7.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
1.7% [1.7%, 1.7%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-7.5% [-7.5%, -7.5%] 1
All ❌✅ (primary) 1.7% [1.7%, 1.7%] 1

Cycles

Results (primary -2.5%, secondary 2.6%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.6% [2.4%, 2.7%] 2
Improvements ✅
(primary)
-2.5% [-2.5%, -2.4%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.5% [-2.5%, -2.4%] 2

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 482.657s -> 481.396s (-0.26%)
Artifact size: 397.96 MiB -> 397.80 MiB (-0.04%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants